#!/bin/sh
# This shell script installs m4 Mathomatic with trig functions that use degree units.
# If this is a source distribution, you should change directory to its root,
# and compile Mathomatic and "sudo make m4install-degrees" to install everything.
# If this is a binary distribution, you should type "sudo ./matho-install-degrees"
# from this directory to install the program files and man pages.

PREFIX=/usr/local
BINDIR=$PREFIX/bin
MANDIR=$PREFIX/share/man/man1
MAN1="mathomatic.1 rmath.1"
MATHOMATIC=mathomatic
if [ ! -x "$MATHOMATIC" ]
then
	MATHOMATIC="../$MATHOMATIC"
fi
if [ ! -x "$MATHOMATIC" ]
then
	echo mathomatic executable not found.
	exit
fi

echo Installing "$MATHOMATIC" to "$BINDIR"
set -x
mkdir -p $BINDIR
mkdir -p $MANDIR
cp $MAN1 $MANDIR
ln -sf $MANDIR/rmath.1 $MANDIR/matho.1
cp "$MATHOMATIC" functions.m4 matho rmath "$BINDIR" &&
cat degrees.m4 >>"$BINDIR"/functions.m4 && echo Done! && exit
echo
echo Usage: sudo $0
